package J.算法.回溯算法;

import java.util.ArrayList;
import java.util.List;

/**
 * 直接再backtrack里加入选择以cur
 */
public class _78_子集 {

    List<List<Integer>> res = new ArrayList<>();
    public List<List<Integer>> subsets(int[] nums) {
        List<Integer> track = new ArrayList<>();
        backtrack(nums,track,0);
        return res;

    }

    public void backtrack(int[] nums,List<Integer> track,int start){
        //操作
        res.add(new ArrayList<>(track));

        for (int i =start; i < nums.length; i++) {
            track.add(nums[i]);
            backtrack(nums,track,i+1);
            track.remove(track.size()-1);
            
        }


    }

}
